package com.software.demo3;

import com.software.utils.HibernateUtils;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class Run {
    public static void main(String[] args) {
        Run run = new Run();
        run.save();
    }
    public void save() {
        Session session = HibernateUtils.getSession();
        Transaction transaction = session.beginTransaction();
        Contract contract = new Contract();
        contract.setPhone("177XXXX3006");
        contract.setEmail("xxx@qq.com");

        Address homeAddress = new Address();
        homeAddress.setProvince("河北省");
        homeAddress.setCity("石家庄市");
        homeAddress.setDistrict("长安区");
        homeAddress.setDetail("谈固北大街你猜号");

        Address workAddress = new Address();
        workAddress.setProvince("河北省");
        workAddress.setCity("石家庄市");
        workAddress.setDistrict("裕华区");
        workAddress.setDetail("南二环东路20号");

        contract.setHomeAddress(homeAddress);
        contract.setWorkAddress(workAddress);

        session.save(contract);

        transaction.commit();
        session.close();
    }
}
